package com.leyou.user.web;

import com.leyou.user.dto.AddressDTO;
import com.leyou.user.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: wangzibeng
 * Date: 2019/5/20 0020
 * Time: 14:25
 */

@RestController
public class AddressController {
    @Autowired
    private AddressService addressService;

    @GetMapping("address")
    public ResponseEntity<List<AddressDTO>> queryAddresses(@RequestParam("uid") Long uid) {
        return ResponseEntity.ok(addressService.queryAddresses(uid));
    }

    @GetMapping("address/buy")
    public ResponseEntity<AddressDTO> queryAddressByUidAndId(@RequestParam("uid") Long uid, @RequestParam("id") Long id) {
        return ResponseEntity.ok(addressService.queryAddressByUidAndId(uid, id));
    }
}
